<template>
  <div class="audition157">
    <v-md-preview :text="text1" />
  </div>
</template>

<script>
const prefix = '``` js'
const suffix = '```'
export default {
  name: 'Audition157',
  data() {
    return {
      text1: `${prefix}
      var str = 'abbbdcda'
      var obj = {}
      var count = function (str) {
        var _len = str.length
        if (_len > 0) {
          var s1 = str[0]
          var str1 = str.replaceAll(s1, '')
          var _len1 = str1.length
          obj[s1] = _len - _len1
          count(str1)
        }
      }
      count(str)
      console.log(obj) // {a: 2, b: 3, d: 2, c: 1}
      var v = Object.values(obj)
      var max = Math.max(...v)
      var k = Object.keys(obj)
      var s = k[v.indexOf(max)]
      console.log(s + '出现次数最多，为' + max +' 次。')
      // b出现次数最多，为3次。
      \n${suffix}`,
    }
  }
}
</script>

<style>

</style>